import xlwt

#读取文本数据
date = []
with open("date3.csv","r") as f :
    date = f.readlines()
    f.close()

#整理格式,去除分隔符
for i in range(len(date)) :
    date[i] = date[i].split(",")



n = len(date) + 1
m = len(date[0]) + 1
workbook = xlwt.Workbook(encoding='utf-8', style_compression=0)

#获取表格页
s = workbook.add_sheet('实验1', cell_overwrite_ok=False)

style = xlwt.XFStyle()

b = ["零件1","零件2","成品","拆解","零件1次品率","零件1次品率""成品次品率","每次最大利润"]

for i in range(1,len(b) + 1):
    s.write(0, i, b[i- 1])

a = 0
for i in range(1,n) :
    for j in range(1,m):
        s.write(i,j,date[i - 1][j - 1])



workbook.save('question4_2_date.xls')
